

function validateManageShippingOption(){
    var error = "";
 
	var serviceName = trim(document.mainform.ds_service_name.value);
    if (serviceName == "") {
        error += "&nbsp;&bull; Please give service name.<br/>";
    }
	var deliveryTime = trim(document.mainform.ds_delivery_time.value);
    if (deliveryTime == "") {
        error += "&nbsp;&bull; Please specify delivery time.<br/>";
    }	
	else if (!isValidNumber(deliveryTime)) {
		error += "&nbsp;&bull; Delivery time must be a positive whole number.<br/>";
	}
	var guaranteed = trim(document.mainform.ds_guaranteed.value);
    if (guaranteed == "") {
        error += "&nbsp;&bull; Please specify if delivery is guaranteed.<br/>";
    }	


	
	var maxWidth = trim(document.mainform.ds_max_width.value);
	if (maxWidth == "") {
        error += "&nbsp;&bull; Please give maximum width.<br/>";
    }
	else if (!isValidNumber(maxWidth)) {
		error += "&nbsp;&bull; Maximum width must be a positive whole number.<br/>";
	}	
		
	var maxHeight = trim(document.mainform.ds_max_height.value);
	if (maxHeight == "") {
        error += "&nbsp;&bull; Please give maximum height.<br/>";
    }	
	else if (!isValidNumber(maxHeight)) {
		error += "&nbsp;&bull; Maximum height must be a positive whole number.<br/>";
	}
		
	var maxLength = trim(document.mainform.ds_max_length.value);
	if (maxLength == "") {
        error += "&nbsp;&bull; Please give maximum length.<br/>";
    }	
	else if (!isValidNumber(maxLength)) {
		error += "&nbsp;&bull; Maximum length must be a positive whole number.<br/>";
	}
		
	var status = trim(document.mainform.ds_status.value);
    if (status == "") {
        error += "&nbsp;&bull; Please specify if service should be active.<br/>";
    }		
	var weightLimit0 = trim(document.mainform.dc_weight_limit_0.value);
	var price0 = trim(document.mainform.dc_price_0.value);
	if (price0 == "" || weightLimit0 == "") {
		error += "&nbsp;&bull; Specify at least one weight-price combination. <br/>";
	}
	for (i = 0; i < 10; i++) {
		var weightLimitElem = trim(document.getElementById("dc_weight_limit_" + i).value);
		var priceElem = trim(document.getElementById("dc_price_" + i).value);
		if (!(priceElem == "" && weightLimitElem == "")) {
			if (priceElem == "" || weightLimitElem == "") {
				error += "&nbsp;&bull; Both weight and price must be given.<br/>";
			}
			else {
				if (!isValidPriceOrMeasurement(priceElem)) {
					error += "&nbsp;&bull; " + priceElem + " is not a valid price.<br/>";
				}
				if (!isValidNumber(weightLimitElem)) {
					error += "&nbsp;&bull; " + weightLimitElem + " is not valid for weight. <br/>";
				}
			}
		}
	}
	return decideOnSubmit(error);    
} 

function showWeightPricePair() {
	var browser = navigator.appName;
    if (browser == "Microsoft Internet Explorer") {
		for (i = 1; i < 10; i++) {
			elem = document.getElementById("weigthPricePair" + i);
			if (elem.style.display == "none") {
				elem.style.display = "block";
				break;
			}
		}         
    }
    else if (browser == "Netscape") {
		for (i = 1; i < 10; i++) {
			elem = document.getElementById("weigthPricePair" + i);
			//alert("elemstyle:" +i + ": " +elem.style.display);
			if (elem.style.display == "none") {
				elem.setAttribute( 'style', 'display:table-row' );
				break;
			}
		}           
    }
}

function hideWeightPricePair() {
	var browser = navigator.appName;
    if (browser == "Microsoft Internet Explorer") {
		for (i = 9; i >= 1; i--) {
			elem = document.getElementById("weigthPricePair" + i);
			if (elem.style.display == "block" || elem.style.display == "") {
				elem.style.display = "none";
				document.getElementById("dc_weight_limit_" + i).value = "";
				document.getElementById("dc_price_" + i).value = "";
				break;
			}
		}        
    }
    else if (browser == "Netscape") {
		for (i = 9; i >= 1; i--) {
			elem = document.getElementById("weigthPricePair" + i);
				//alert("elemstyle" +i + ": "+elem.style.display);
			if (elem.style.display == "table-row" || elem.style.display == "") {
				//elem.style.display = "none";
				elem.setAttribute( 'style', 'display:none' );
				document.getElementById("dc_weight_limit_" + i).value = "";
				document.getElementById("dc_price_" + i).value = "";				
				break;
			}
		}    
    }
}



